
<template>
  <div>
    <!-- 添加商品 -->
    <el-button @click="go2GoodsAdd" plain type="success">添加商品</el-button>
    <!-- 表格 -->
    <el-table :data="goodsList" style="width: 100%">
      <el-table-column type="index"></el-table-column>
      <el-table-column prop="goods_name" label="商品名称" width="180"></el-table-column>
      <el-table-column prop="goods_price" label="商品价值" width="180"></el-table-column>
      <el-table-column prop="goods_number" label="商品数量"></el-table-column>
      <el-table-column prop="add_time" label="创建时间"></el-table-column>
      <el-table-column label="操作"></el-table-column>
    </el-table>
  </div>
</template>

<script>
/* eslint-disable */
export default {
  data() {
    return {
      goodsList: [
        {
          goods_name: "",
          goods_price: "",
          goods_number: "",
          add_time: ""
        }
      ]
    };
  },
  created() {
    this.loadGoodsList();
  },
  methods: {
    // 加载 商品数据 4个
    async loadGoodsList() {
      let res = await this.$axios.get("goods", {
        params: {
          query: "",
          pagenum: 1,
          pagesize: 4
        }
      });
      console.log(res);
      this.goodsList = res.data.data.goods;
    },
    // 跳转到添加商品页面
    go2GoodsAdd() {
      this.$router.push("/goods-add");
    }
  }
};
</script>

<style>
</style>
